import Vue from 'vue'
import VueRouter from 'vue-router'
// 布局文件
import AppLayOut from '../layout/AppLayOut.vue'

Vue.use(VueRouter)

// 解决重复点击路由报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
    return originalPush.call(this, location).catch(err => err)
}
const routes = [

    {
        path: '/',
        name: 'IndexLayout',
        component: AppLayOut,
        children: [{
            path: "/",
            name: '/',
            component: () => import('../views/index/IndexLayOut.vue')
        },
            {
                path: '/Video',
                name: 'Video',
                component: () => import('../views/video/VideoLayout.vue')
            },

            {
                path: '/SearchPage',
                name: 'SearchPage',
                component: () => import('../views/search/SearchPage')
            },
            {
                path: '/LoginPage',
                name: 'LoginPage',
                meta:{
                    islogin:true
                },
                component: () => import('../views/login/LoginPage')
            },
        ]

    },
    {
        path: "/CommentDetail",
        name: 'CommentDetail',
        component: () => import('../views/video/components/CommentDetail.vue')
    },

    {
        path: "/CommentDetail",
        name: 'CommentDetail',
        component: () => import('../views/video/components/CommentDetail.vue')
    },
    {
        path: '/SearchPage',
        name: 'SearchPage',
        component: () => import('../views/search/SearchPage')
    },
    {
        path: '/DetailsNews/:articleId',
        name: '/DetailsNews',
        component: () => import('../components/DetailsNews')
    },
    {
        path: '/Register',
        name: 'Register',
        component: () => import('../views/login/components/Register')
    },
    {
        path: '/Logining',
        name: 'Logining',
        component: () => import('../views/login/components/Logining')
    },
    {
        path: '/ForgetThePassword',
        name: 'ForgetThePassword',
        component: () => import('../views/login/components/ForgetThePassword')
    },
    {
        path: '/MyCollect',
        name: 'MyCollect',
        meta:{
            isCollect:true
        },
        component: () => import('../views/login/components/MyCollect')
    },
    {
        path: '/AdvPicture',
        name: 'AdvPicture',
        component: () => import('../views/corver/AdvPicture')
    },
    {
        path: '/MyInformation',
        name: 'MyInformation',
        component: () => import('../views/login/components/MyInformation')
    },
]


const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

// router.beforeEach((to,from,next)=>{
//     if(to.meta.islogin){
//         to.meta.islogin=false
//         next("/Logining")
//     }
//     // if(to.meta.isCollect){
//     //     to.meta.isCollect=false
//     //     next("/Logining")
//     // }
//     next()
// })



export default router
